import $api from "@/api/index.js"
import $i18n from "@/utils/i18n.js" // 多语言
export default {
	state: {
		merchantInfo: '', // 商家信息
	},
	mutations: {
		// 更新内容
		async updateMerchantState(state, item) {
			let {
				key,
				val
			} = item
			state[key] = val
			if (['merchantInfo'].includes(key)) {
				uni.setStorageSync(key, val)
			}
		}
	},
	actions: {
		
		// 获取商家信息
		async getMerchantInfo({
			commit,
			state
		}, param) {
			if(!state.authToken)return;
			let res = await $api.user.getUserInfo()
			if(res.code == 200){
				commit('updateUserState', {
					key: 'userInfo',
					val: res.data
				})
			}
			// let data = res.code == 200 ? res.data : ''
		},
		
		
	}
}
